package com.ssm.platform.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.ssm.platform.service.IDynamicDataSourceService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class DynamicDataSourceServiceImpl implements IDynamicDataSourceService {
    final ApplicationContext context;

    @Override
    @DSTransactional
    public void save() {
        IDynamicDataSourceService dynamicDataSourceService = context.getBean(IDynamicDataSourceService.class);
        dynamicDataSourceService.saveMySQL();
        dynamicDataSourceService.saveOracle();
        dynamicDataSourceService.saveH2();
    }

    @Override
    @DS("mysql")
    public Boolean saveMySQL() {
        return null;
    }

    @Override
    @DS("oracle")
    public Boolean saveOracle() {
        return null;
    }

    @Override
    @DS("h2")
    public Boolean saveH2() {
        return null;
    }
}
